package ss.pku.jsa.type.inference;

public class ArrayFieldKey extends FieldKey {
	// private static final String ELEMENT_KEY = "_elementFK";
	private static final ArrayFieldKey PRIMITIVE_KEY = new ArrayFieldKey("prim");
	private static final ArrayFieldKey OBJECT_KEY = new ArrayFieldKey("obj");
	private String kind;

	private ArrayFieldKey(String kind) {
		this.kind = kind;
		this.name = kind;
	}

	public static FieldKey getInstance(RefQType contents) {
		if ((contents.deref() instanceof ObjectQType)) {
			return OBJECT_KEY;
		}
		return PRIMITIVE_KEY;
	}

	public String toString() {
		return "_elementFK_" + this.kind;
	}

	public String getShortName() {
		return toString();
	}

	public TypeKey getDeclaringType() {
		throw new UnsupportedOperationException(
				"Declaring type is undefined for array fields, since they are shared.");
	}
}
